home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6089 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: fc.hp.com!news
  2. From: Rick Wells <rwells>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A Linked List Problem
  5. Date: 22 Feb 1996 16:59:32 GMT
  6. Organization: Hewlett-Packard Fort Collins Site
  7. Message-ID: <4gi7dk$alk@fcnews.fc.hp.com>
  8. References: <96053.015114X60CC@CUNYVM.CUNY.EDU>
  9. NNTP-Posting-Host: blkbear.fc.hp.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/715)
  14. X-URL: news:96053.015114X60CC@CUNYVM.CUNY.EDU
  15.  
  16. SHAHZAD ANJUM MALIK <X60CC@CUNYVM.CUNY.EDU> wrote:
  17. >Hi!
  18. >    I am trying to create a small program using Linked Lists. Actually, I
  19. >am planning to use Linked Lists in Linked Lists. A simple application of the
  20. >program would be to add a customer name etc and then add a magazine to be
  21. >subscribed to the customer, and if the customer wants add a 2nd and 3rd and
  22. >so on. For adding new customers I am using Linked Lists of nested structures.
  23. >Structures look like this:
  24. >struct CustName
  25. >     {
  26. >     char LastName[15];
  27. >     char ID#[5];
  28. >     };
  29. >struct Magazine
  30. >     {
  31. >     char MagName[20];
  32. >     struct Magazine *nextMag;
  33. >     };
  34. >struct CustProfile
  35. >     {
  36. >     struct CustName Name;
  37. >     struct Magazine Mag;
  38. >     struct CustProfile *next;
  39. >     };
  40. >typedef struct CustProfile ELEMENT;
  41. >typedef ELEMENT *LINK;
  42.     .
  43.     .
  44.     .
  45. >      current->Mag = current->Mag.nextMag;
  46. >      current->next = NULL;
  47. >}
  48. >     The problem is that the complier (MSC 6.00) gives syntax error on the
  49. >     2nd last line. I have been trying to remove the mistake for several
  50. >     days but useless. The error for "current->Mag = current->Mag.nextMag"
  51. >     is " Erro No. '=' incompatible types.
  52.     .
  53.     .
  54.     .
  55.  
  56. Your problem is that Mag in structure CustProfile is not a pointer where
  57. current->Mag.nextMag is. You need to change Mag to be
  58.  
  59.     struct Magazine *Mag;
  60.  
  61. Of course, you will also have to change your other code (not shown above)
  62. to reflect the change such as dereferencing Mag when you access it's
  63. elements and you will have to malloc structures of type struct Magazine
  64. and add them to your Mag list.
  65.  
  66. Hope this helps, Rick
  67.  
  68.